package com.ty.bigevent.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ty.bigevent.model.entry.Article;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author ong char
* @description 针对表【article】的数据库操作Mapper
* @createDate 2025-09-27 00:58:11
* @Entity com.ty.bigevent.model.entry.Article
*/
public interface ArticleMapper extends BaseMapper<Article> {

    @Insert("insert into article(title,content,cover_img,state,category_id,create_user,create_time,update_time) values(#{title},#{content},#{cover_img},#{state},#{category_id},#{create_user},now(),now())")
    void addArticle(Article article);

    @Update("update article set title=#{title},content=#{content},cover_img=#{cover_img},state=#{state},category_id=#{category_id},update_time=now() where id=#{id}")
    void updateArticle(Article article);

    IPage<Article> listArticle(Page<Article> page, @Param("userId") Integer userId,@Param("categoryId") Integer categoryId,@Param("state") String state);

    @Select("select * from article where id=#{id}")
    Article getArticleById(@Param("id") Integer id);

    @Delete("delete from article where id=#{id}")
    void deleteArticleById(@Param("id") Integer id);
}




